package com.hifar.test.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hifar.test.test.mapper.HfEnvTestPieceMapper;
import com.hifar.test.test.pojo.HfEnvTestPiece;
import com.hifar.test.test.service.IHfEnvTestPieceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 委托单样品 服务实现类
 * </p>
 *
 * @author wei
 * @since 2024-12-04 15:51:56
 */
@Service
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class HfEnvTestPieceServiceImpl extends ServiceImpl<HfEnvTestPieceMapper, HfEnvTestPiece> implements IHfEnvTestPieceService {
    @Override
    public List<HfEnvTestPiece> listPieceByTestId(String id) {
        QueryWrapper<HfEnvTestPiece> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(HfEnvTestPiece::getTestId, id)
                .orderByAsc(HfEnvTestPiece::getRowSort);
        return this.list(queryWrapper);
    }

    @Override
    public List<HfEnvTestPiece> listPieceByTestIds(List<String> idList) {
        QueryWrapper<HfEnvTestPiece> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .in(HfEnvTestPiece::getTestId, idList)
                .orderByAsc(HfEnvTestPiece::getRowSort);
        return this.list(queryWrapper);
    }

    @Override
    public void removeByTestId(String testId) {
        QueryWrapper<HfEnvTestPiece> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(HfEnvTestPiece::getTestId, testId);
        this.remove(queryWrapper);
    }
}
